﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;

namespace ServConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 9997);
            sock.Bind(ipep);
            EndPoint ep = ipep as EndPoint;
            Byte[] buf = new Byte[1024];
            while (true)
            {
                sock.ReceiveFrom(buf, ref ep);
                Console.WriteLine(Encoding.UTF8.GetString(buf).TrimEnd('\0'));
            }
            sock.Close();
        }
    }
}
